package com.spaceobj.chess.common;

import lombok.Data;

@Data
public class Message {
    private MessageType type;        // 消息类型
    private String roomId;           // 房间ID（游戏ID或聊天室ID）
    private Long timestamp;          // 时间戳
    private Object data;             // 消息内容
    private Integer fromUserId;      // 发送者ID
    private Integer toUserId;        // 接收者ID（可选）

    public Message() {
        this.timestamp = System.currentTimeMillis();
    }

    public Message(MessageType type) {
        this.type = type;
        this.timestamp = System.currentTimeMillis();
    }

    public Message(MessageType type, Object data) {
        this.type = type;
        this.data = data;
        this.timestamp = System.currentTimeMillis();
    }

    public Message(MessageType type, String roomId, Object data) {
        this.type = type;
        this.roomId = roomId;
        this.data = data;
        this.timestamp = System.currentTimeMillis();
    }

    public MessageType getType() {
        return type;
    }

    public void setType(MessageType type) {
        this.type = type;
    }

    public String getRoomId() {
        return roomId;
    }

    public void setRoomId(String roomId) {
        this.roomId = roomId;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getFromUserId() {
        return fromUserId;
    }

    public void setFromUserId(Integer fromUserId) {
        this.fromUserId = fromUserId;
    }

    public Integer getToUserId() {
        return toUserId;
    }

    public void setToUserId(Integer toUserId) {
        this.toUserId = toUserId;
    }
} 